package com.cy.util;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

import javax.servlet.http.HttpServletRequest;

/**
 * Description: 添加描述
 * date: 2021/3/19 0019 17:13
 *
 * @author Mr.xiaoshi
 * @since JDK 1.8
 */
public class PageUtil {
    public static <T>Page<T> startPage(){
        /*获取请求对象*/
        HttpServletRequest request = ServletUtil.getRequest();
        /*获取请求中的分页参数的值*/
        String pageCurrentStr = request.getParameter("pageCurrent");
        String pageSize = request.getParameter("pageSize");
        /*将字符串类型的参数值转换为int的包装类型*/
        return PageHelper.startPage(StringUtil.isEmpty(pageCurrentStr)?1:Integer.parseInt(pageCurrentStr),
                                    StringUtil.isEmpty(pageSize)?10:Integer.parseInt(pageSize));
    }
}
